<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link th:replace="includes :: link">
    <script th:replace="includes :: script"></script>
    <style th:replace="includes :: style"></style>
    <link th:href="@{css/page.css}" rel="stylesheet" />
</head>
<body>
<div class="layui-anim layui-anim-fadein" style="padding:15px">
    <div class="layui-card">
        <!--        <div class="layui-card-header">表格</div>-->
        <div class="layui-card-body">
            <div class="layui-form layui-form-pane data-view-pane"  style="margin-top: 16px;">
                <div class="layui-form-item  layui-inline">
                    <label class="layui-form-label">开始FPD(含)</label>
                    <div class="layui-input-inline">
                        <input type="number" step="0.01" name="dataStart" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item layui-inline">
                    <label class="layui-form-label">结束FPD(含)</label>
                    <div class="layui-input-inline">
                        <input type="number" step="0.01" name="dataEnd" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item layui-inline">
                    <label class="layui-form-label">机组</label>
                    <div class="layui-input-inline">
                        <select id="unitCode">
                            <option value="'TQNPC-1'">1号机组</option>
                            <option value="'TQNPC-2'">2号机组</option>
                            <option value="'TQNPC-1','TQNPC-2'" selected>1号和2号机组</option>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item layui-inline">
                    <button id="restruct-btn" class="layui-btn">数据整合</button>
                </div>
            </div>
            <div class="data-table">
                <div class="table-title">
                    <span>Channel表</span>
                    <!--<form>-->
<!--                    <input id="show-data-btn" type="button" class="layui-btn layui-btn-sm" value="数据整合">-->
                    <!--    </form>-->
                </div>
                <table class="layui-hide" id="channel_shd"></table>
            </div>

            <!--            <table class="layui-hide" id="shd">数据分布(个别字段)</table>-->
            <div class="data-table">
                <div class="table-title">
                    <span>Reactor表</span>
                </div>
                <table class="layui-hide" id="reactor_shd"></table>
            </div>
            <div class="data-table">
                <div class="table-title">
                    <span>Reload表</span>
                </div>
                <table class="layui-hide" id="reload_shd"></table>
            </div>
        </div>
    </div>
</div>

<script>
    /*<![CDATA[*/

    $("#restruct-btn").on('click', function () {
        var dataStart = $('[name=dataStart]').val();
        var dataEnd = $('[name=dataEnd]').val();
        var unitCode = $('#unitCode').val();
        console.log(dataStart);
        $.ajax({
            url: "show_data",
            data: {
                fpd_from: dataStart,
                fpd_end: dataEnd,
                unitCode: unitCode
            },
            success:function (result) {
              console.log("restruct is finished!")
            }
        });

        //
        // var i = 0;
        // var interval = setInterval(function () {
        //     i++;
        //     // $.get('channel_done',
        //     //     function (result) {
        //     //         console.log(result);
        //     //     }
        //     // );
        //
        //     $.ajax({
        //         url: 'channel_done',
        //         data: {},
        //         success: function (result) {
        //             console.log(result);
        //         }
        //     });
        //     if (i == 5) {
        //         clearInterval(interval);
        //     }
        // }, 1000);

    });

    //
    // $.get('show_data', function (result) {
    //     console.log(result)
    // });

    layui.use('table', function () {
        var table = layui.table;

        var option = {
            id: 'shd',
            elem: '#shd',
            // url: 'test',
            cellMinWidth: 40,
            cols: [],
            pagination: true,
            even: true,
            response: {},
            parseData: function (data) {
                // var fields = _.range(1,22);
                var cols = _.chain(data).sample().keys().map(function (k) {
                    return {field: k, title: k, sort: false, align: 'center'}
                }).value();

                this.cols[0] = cols;
                // console.log(this.cols);
                return {
                    "data": data
                };
            }
        };
        table.render(option);
        // $('#show-data-btn').on('click', function () {
        //
        //     table.reload('shd', {
        //         // cols:[],
        //         url: 'show_data',
        //         pagination: {
        //             curr: 1 //重新从第 1 页开始
        //         }
        //     }, 'data');
        // });
    });
    /*]]>*/
</script>
<script>
    /*<![CDATA[*/
    // $.get('channel_list', function (result) {
    //     console.log(result)
    // });

    layui.use('table', function () {
        var table = layui.table;

        var option = {
            id: 'channel_shd',
            elem: '#channel_shd',
            url: 'channel_list',
            where: {CHCODE: 'A09'},
            cellMinWidth: 70,
            even: false,
            cols: [
                [
                    {field: 'fpd', title: '满功率日', sort: true, align : 'center'}
                    , {field: 'chcode', title: '通道编号', sort: true, align : 'center'}
                    , {field: 'unitcode', title: '机组编号', sort: true, align : 'center'}
                    , {field: 'pmchpdistribute', title: '通道功率', align : 'center'}
                    , {field: 'pmrergain', title: '反应性增益', minWidth: 100, align : 'center'} //minWidth：局部定义当前单元格的最小宽度，layui 2.2.1 新增
                    , {field: 'pmavgodburnup', title: '平均出口卸料燃耗', align : 'center'}
                    , {field: 'pmmbp', title: '最大棒束功率', align : 'center'}
                    , {field: 'chresidencetime', title: '通道驻留时间', align : 'center'}
                ]
            ],
            page: true,
            response: {},
            parseData: function (data) {
            }
        };

        table.render(option);
    });
    /*]]>*/
</script>
<script>
    /*<![CDATA[*/

    layui.use('table', function () {
        var table = layui.table;

        var option = {
            id: 'reactor_shd',
            elem: '#reactor_shd',
            url: 'reactor_list',
            cellMinWidth: 70,
            even: false,
            cols: [
                [
                    {field: 'fpd', title: '满功率日', sort: true, align : 'center', width: '120'}
                    , {field: 'unitcode', title: '机组编号', align : 'center', width: '120'}
                    , {field: 'calbconcentration', title: '计算出的硼浓度', align : 'center', width: '130'}
                    , {field: 'initavglvl', title: '平均液位', align : 'center', width: '100'}
                    , {field: 'zoneinitlvldev1', title: '1区域初始液位', align : 'center', width: '130'}
                    , {field: 'zoneinitlvldev2', title: '2区域初始液位', align : 'center', width: '130'}
                    , {field: 'zoneinitlvldev3', title: '3区域初始液位', align : 'center', width: '130'}
                    , {field: 'zoneinitlvldev4', title: '4区域初始液位', align : 'center', width: '130'}
                    , {field: 'zoneinitlvldev5', title: '5区域初始液位', align : 'center', width: '130'}
                    , {field: 'zoneinitlvldev6', title: '6区域初始液位', align : 'center', width: '130'}
                    , {field: 'zoneinitlvldev7', title: '7区域初始液位', align : 'center', width: '130'}
                    , {field: 'zoneinitlvldev8', title: '8区域初始液位', align : 'center', width: '130'}
                    , {field: 'zoneinitlvldev9', title: '9区域初始液位', align : 'center', width: '130'}
                    , {field: 'zoneinitlvldev10', title: '10区域初始液位', align : 'center', width: '130'}
                    , {field: 'zoneinitlvldev11', title: '11区域初始液位', align : 'center', width: '130'}
                    , {field: 'zoneinitlvldev12', title: '12区域初始液位', align : 'center', width: '130'}
                    , {field: 'zoneinitlvldev13', title: '13区域初始液位', align : 'center', width: '130'}
                    , {field: 'zoneinitlvldev14', title: '14区域初始液位', align : 'center', width: '130'}
                ]
            ],
            page: true,
            response: {},
            parseData: function (data) {
            }
        };

        table.render(option);

    });
    /*]]>*/
</script>
<script>
    /*<![CDATA[*/
    // $.get('channel_list', function (result) {
    //     console.log(result)
    // });

    layui.use('table', function () {
        var table = layui.table;

        var option = {
            id: 'reload_shd',
            elem: '#reload_shd',
            url: 'reload_list',
            cellMinWidth: 70,
            even: false,
            cols: [
                [
                    {field: 'fpd', title: '满功率日', sort: true, align : 'center'}
                    , {field: 'chcode', title: '通道编号', sort: true, align : 'center'}
                    , {field: 'unitid', title: '机组编号', sort: true, align : 'center'}
                ]
            ],
            page: true,
            response: {},
            parseData: function (data) {
            }
        };

        table.render(option);
    });
    /*]]>*/
</script>
<script>
    $(function () {
        $('layui-laypage-btn')
    });
</script>
</body>
</html>